/**
 * @program: HelpLuojia
 * @description: 失物招领controller
 * @author: PXM
 * @create: 2022-11-21 19:09
 **/
package com.whu.helpluojia.controller;

import com.whu.helpluojia.common.BaseContext;
import com.whu.helpluojia.common.R;
import com.whu.helpluojia.domain.Find;
import com.whu.helpluojia.domain.LostAndFound;
import com.whu.helpluojia.service.LostAndFoundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/laf")
//捡东西
public class LostAndFoundController {

    @Autowired
    LostAndFoundService lostAndFoundService;

    /**
     * 增加一条寻物启事
     * @param lostAndFound
     * @return
     */
    @PostMapping("/insert")
    public void insert(@RequestBody LostAndFound lostAndFound){
        Long userId= BaseContext.getCurrentId();
        lostAndFound.setUserId(userId);
        lostAndFound.setTime(new Date());
        lostAndFoundService.insert(lostAndFound);
    }

    @GetMapping("/{id}")
    public LostAndFound getLAFById(@PathVariable Long id){
        return lostAndFoundService.getById(id);
    }
}
